<template>
	<section v-loading="listLoading">
		<!--工具条-->
		<el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
			<el-form :inline="true" :model="filters">
				<el-form-item label="类型">
                    <el-select v-model="filters.type" clearable> 
                        <el-option v-for="item in option" :key="item.value" :label="item.label" :value="item.value"></el-option>
                    </el-select>
				</el-form-item>
				<el-form-item>
					<el-button type="primary" v-on:click="handleCurrentChange(1)">查询</el-button>
				</el-form-item>
			</el-form>
		</el-col>
		<!--列表-->
		<el-table :data="users" stripe highlight-current-row @selection-change="selsChange" border style="width: 100%;">
			<el-table-column prop="id" label="ID" min-width="40" align="center">
			</el-table-column>
			<el-table-column prop="money" label="数量" min-width="80" align="center">
			</el-table-column>
			<el-table-column prop="description" label="描述" min-width="80" align="center">
			</el-table-column>
			<el-table-column label="类型" min-width="80" align="center">
				<template slot-scope="scope">
					<span>{{scope.row.billType===0?'余额' :scope.row.billType===1?'PE' :scope.row.billType===2?'复购积分' :scope.row.billType===3?'消费积分' :'贡献值'}}</span>
				</template>
			</el-table-column>
			<el-table-column prop="createTime" label="创建时间" min-width="100" :formatter="formatDate" align="center">
			</el-table-column>
		</el-table>
		<!--工具条-->
		<el-col :span="24" class="toolbar">
			<el-pagination background layout="prev, pager, next, jumper" @current-change="handleCurrentChange" :page-size="pageSize" :total="total" style="float:right;">
			</el-pagination>
		</el-col>
		
	</section>
</template>

<script>
	import { client } from '../../common/js/alioss'
	import util from '../../common/js/util'
	export default {
		data() {
			return {
				filters: {
					type: '',
				},
				option:[{
					value:'',
					label:'全部'
				},{
					value:'0',
					label:'余额'
				},{
					value:'1',
					label:'PE'
				},{
					value:'2',
					label:'复购积分'
				},{
					value:'3',
					label:'消费积分'
				},{
					value:'4',
					label:'贡献值'
				}],
				users: [],
				list:[],
				sels: [],
				total: 0,
				page: 1,
				pageSize: 10,
				listLoading: false,
			}
		},
		methods: {
			//时间转换开始时间 
			formatDate(row, column) {
                let date = new Date(parseInt(row.createTime));
                let Y = date.getFullYear() + '-';
                let M = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) + '-' : date.getMonth() + 1 + '-';
                let D = date.getDate() < 10 ? '0' + date.getDate() + ' ' : date.getDate() + ' ';
                let h = date.getHours() < 10 ? '0' + date.getHours() + ':' : date.getHours() + ':';
                let m = date.getMinutes()  < 10 ? '0' + date.getMinutes() + ':' : date.getMinutes() + ':';
                let s = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds();
                return Y + M + D + h + m + s;
           },
			handleCurrentChange(val) {
				this.page = val;
				this.getUsers();
			},
			//获取用户列表
			getUsers:function (){
				this.listLoading = true;
				let para = {
					page: this.page,
					limit: this.pageSize,
					userId:this.$route.query.id,
					type:this.filters.type
				};
				
				this.$http.post('walletBill/incomeDetails', this.qs.stringify(para)).then(data => {
					let  res = data.data;
					console.log(data);
					if (res.code !== 200) {
						this.$message({
							message: res.msg,
							type: 'error'
						});
					} else {
						this.total = res.data.totalNum;
						this.users = res.data.items;
						this.listLoading = false;
					}
				});
			},
			selsChange: function (sels) {
				this.sels = sels;
			},
			
		},
		mounted() {
			this.getUsers();
		}
	}

</script>
<style>
</style>
